package com.agann.model;

import java.util.HashMap;
import java.util.Map;

import com.agann.util.Util_Factory;

public class Meme implements Memorable{
	
	public static final int DEFAULT = 10;
	
	/**
	 * The code of Meme, it consists three parts:
	 * #@Type@Args#@Type@Args#...
	 * Denoting each Memory element
	 */
	private String code;
	private Map<String, Memory> memories;
	private Map<String, Double> input;
	
	public Meme(String code) {
		this.code = code;
		memories = new HashMap<String, Memory>();
		String mem[] = code.split("#");
		for (String m : mem) {
			memories.put(m, Util_Factory.createUtil(m));
		}
	}
	
	
	public void learn(String newCode) {
		
	}
	
	public void sense(Record record) {
		
	}

	@Override
	public void update(Record record) {
		//TODO Need improvement on efficiency
		for (String key : memories.keySet()) {
			memories.get(key).update(record);
			input.putAll(memories.get(key).getScores());
		}
		
	}
	
	public String getCode() {
		return code;
	}


	@Override
	public void merge(String code) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void change(double rate) {
		// TODO Auto-generated method stub
		
	}
	

}
